package com.example.lishop.repository

import com.example.lishop.entity.BProductTagEntity
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Modifying
import org.springframework.data.jpa.repository.Query
import org.springframework.transaction.annotation.Transactional
import java.util.*

/**
 * Created on 2021/3/14 18:00
 * @author shuguo
 */
interface ProductTagRepository : JpaRepository<BProductTagEntity, Int>{

    fun findByProductTagId(productTagId: String): BProductTagEntity?

    @Transactional(timeout = 10)
    @Modifying
    @Query("update BProductEntity set sts = '1' where productId = ?1")
    fun del(productTagId: String)

    @Transactional(timeout = 10)
    @Modifying
    @Query("update BProductTagEntity set name = :name, descript = :descript, sts = :sts where productTagId = :productTagId")
    fun update(productTagId:String, name:String, descript:String, sts:String)
}